// 导入数据库操作模块
const db = require('../db/index')
const https = require('https');

//  登录接口处理函数
exports.login = (req,res) => {
    // console.log(req.body.code);
    https.get('https://api.juejin.cn/tag_api/v1/query_category_briefs', res => {
        let list = [];
        res.on('data', chunk => {
            list.push(chunk);
        });
        res.on('end', () => {
            const { data } = JSON.parse(Buffer.concat(list).toString());
            data.forEach(item => {
                console.log(`\${chalk.yellow.bold(item.rank)}.\${chalk.green(item.category_name)}`);
            })
        });
    }).on('error', err => {
        console.log('Error: ', err.message);
    });
}

